package cn.wolfcode.custom.service.impl;

import java.util.List;

import cn.wolfcode.common.utils.DateUtils;
import cn.wolfcode.common.utils.SecurityUtils;
import cn.wolfcode.custom.dto.CustomerLinkmanDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.wolfcode.custom.mapper.CustomerLinkmanMapper;
import cn.wolfcode.custom.domain.CustomerLinkman;
import cn.wolfcode.custom.service.ICustomerLinkmanService;

/**
 * 客户联系人Service业务层处理
 * 
 * @author zhangyf
 * @date 2023-05-02
 */
@Service
public class CustomerLinkmanServiceImpl implements ICustomerLinkmanService 
{
    @Autowired
    private CustomerLinkmanMapper customerLinkmanMapper;

    /**
     * 查询客户联系人
     * 
     * @param id 客户联系人主键
     * @return 客户联系人
     */
    @Override
    public CustomerLinkman selectCustomerLinkmanById(Long id)
    {
        return customerLinkmanMapper.selectCustomerLinkmanById(id);
    }

    /**
     * 查询客户联系人列表
     * 
     * @param customerLinkman 客户联系人
     * @return 客户联系人
     */
    @Override
    public List<CustomerLinkman> selectCustomerLinkmanList(CustomerLinkman customerLinkman)
    {
        return customerLinkmanMapper.selectCustomerLinkmanList(customerLinkman);
    }

    /**
     * 新增客户联系人
     * 
     * @param customerLinkman 客户联系人
     * @return 结果
     */
    @Override
    public int insertCustomerLinkman(CustomerLinkman customerLinkman)
    {
        // 0为在职，1为离职
        customerLinkman.setPositionState(0);
        // 设置当前录入人
        customerLinkman.setInputUser(SecurityUtils.getUserId());
        // 设置当前时间
        customerLinkman.setInputTime(DateUtils.getNowDate());
        return customerLinkmanMapper.insertCustomerLinkman(customerLinkman);
    }

    /**
     * 修改客户联系人
     * 
     * @param customerLinkman 客户联系人
     * @return 结果
     */
    @Override
    public int updateCustomerLinkman(CustomerLinkman customerLinkman)
    {
        return customerLinkmanMapper.updateCustomerLinkman(customerLinkman);
    }

    /**
     * 批量删除客户联系人
     * 
     * @param ids 需要删除的客户联系人主键
     * @return 结果
     */
    @Override
    public int deleteCustomerLinkmanByIds(Long[] ids)
    {
        return customerLinkmanMapper.deleteCustomerLinkmanByIds(ids);
    }

    /**
     * 删除客户联系人信息
     * 
     * @param id 客户联系人主键
     * @return 结果
     */
    @Override
    public int deleteCustomerLinkmanById(Long id)
    {
        return customerLinkmanMapper.deleteCustomerLinkmanById(id);
    }

    @Override
    public List<CustomerLinkman> selectCustomerLinkmanDTOList(CustomerLinkmanDTO customerLinkmanDTO) {

        return customerLinkmanMapper.selectCustomerLinkmanDTOList(customerLinkmanDTO);
    }

    @Override
    public List<CustomerLinkman> selectCustomerLinkmanListNoPage() {
        return customerLinkmanMapper.selectCustomerLinkmanListNoPage();
    }
}
